-
Notifications
You must be signed in to change notification settings - Fork 2.9k
Add anchor attribute #9144
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Add anchor attribute #9144
Changes from 33 commits
95ebedf
cc6d05d
e028845
b7bf329
add4841
b590be2
86f0fc3
81d51b7
3b69887
8bdce1c
610ae3f
87532cc
9ad8934
0489d5b
b5be1a3
f11da28
06049f9
382b064
fb5e5bb
3dca84e
420012f
b354492
85e059f
7da97b5
b88238e
0c02dbb
59d976c
5116e00
acdf3ee
ee9c79f
b7da26d
26a6ab3
b0be02a
f7c6b36
e154788
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4129,8 +4129,13 @@ a.setAttribute('href', 'https://example.com/'); // change the content attribute | |
<li><dfn data-x-href="https://drafts.csswg.org/css-contain/#content-visibility">'content-visibility'</dfn> property</li> | ||
<li><dfn data-x-href="https://drafts.csswg.org/css-contain/#propdef-content-visibility" data-x="content-visibility-auto">'auto'</dfn> value for <span>'content-visibility'</span></li> | ||
</ul> | ||
</dd> | ||
|
||
<p>The following terms are defined in <cite>CSS Anchor Positioning</cite>: <ref>CSSANCHOR</ref></p> | ||
|
||
<ul class="brief"> | ||
<li><dfn data-x-href="https://drafts.csswg.org/css-anchor-position-1/#implicit-anchor-element">implicit anchor element</dfn></li> | ||
</ul> | ||
</dd> | ||
|
||
<dt>Intersection Observer</dt> | ||
|
||
|
@@ -11771,6 +11776,9 @@ interface <dfn interface>HTMLElement</dfn> : <span>Element</span> { | |
undefined <span data-x="dom-hidePopover">hidePopover</span>(); | ||
boolean <span data-x="dom-togglePopover">togglePopover</span>(optional boolean force); | ||
[<span>CEReactions</span>] attribute DOMString? <span data-x="dom-popover">popover</span>; | ||
|
||
// The anchor attribute | ||
[<span>CEReactions</span>] attribute Element? <span data-x="dom-anchorElement">anchorElement</span>; | ||
josepharhar marked this conversation as resolved.
Show resolved
Hide resolved
|
||
}; | ||
|
||
<span>HTMLElement</span> includes <span>GlobalEventHandlers</span>; | ||
|
@@ -13005,6 +13013,7 @@ https://software.hixie.ch/utilities/js/live-dom-viewer/?%3C%21DOCTYPE%20HTML%3E% | |
|
||
<ul class="brief"> | ||
<li><code data-x="attr-accesskey">accesskey</code></li> | ||
<li><code data-x="attr-anchor">anchor</code></li> | ||
<li><code data-x="attr-autocapitalize">autocapitalize</code></li> | ||
<li><code data-x="attr-fe-autofocus">autofocus</code></li> | ||
<li><code data-x="attr-contenteditable">contenteditable</code></li> | ||
|
@@ -14011,6 +14020,47 @@ background: transparent">blue</span>.</p></code></pre> | |
</div> | ||
|
||
|
||
<h5>The <code data-x="attr-anchor">anchor</code> attribute</h5> | ||
|
||
<p>If an <span data-x="HTML elements">HTML element</span> has an <dfn element-attr | ||
foolip marked this conversation as resolved.
Show resolved
Hide resolved
|
||
for="html-global"><code data-x="attr-anchor">anchor</code></dfn> attribute specified, then that | ||
josepharhar marked this conversation as resolved.
Show resolved
Hide resolved
|
||
attribute's value must be the <span data-x="concept-ID">ID</span> of an element in the same | ||
<span>tree</span> as the element with the <code data-x="attr-anchor">anchor</code> attribute. The | ||
<code data-x="attr-anchor">anchor</code> attribute allows authors to set a <span | ||
data-x="referenced">reference</span> to the <span>implicit anchor element</span>. | ||
<ref>CSSANCHOR</ref></p> | ||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Didn't catch this before, but "get an attribute by name" will return an There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The reason I used "get an attribute by name" is because it uses the Can I just extract the element from the Attr somehow...? Or should I just copy exactly what https://html.spec.whatwg.org/#attr-label-for does? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The bit you could copy and adjust from https://html.spec.whatwg.org/#attr-label-for is:
I don't think you have any use of an There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ok, I did my best to merge this paragraph into the above one and replace the text with the attr-label-for text. how does it look? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This still seems broken to me by the way in the popover section. The step only gives you an attribute, but the next step assumes it's a node. |
||
<p>For an <span data-x="HTML elements">HTML element</span> <var>element</var>, its <span>implicit | ||
anchor element</span> is the result of running <span>get an attribute by name</span> given | ||
<var>element</var> and <code data-x="attr-anchor">anchor</code>.</p> | ||
|
||
<p>The <dfn data-x="dom-anchorElement"><code>anchorElement</code></dfn> IDL attribute must | ||
<span>reflect</span> the <code data-x="attr-anchor">anchor</code> attribute. | ||
|
||
<div class="example"> | ||
<p>The following example shows how to use CSS anchor positioning by using the <code | ||
data-x="attr-anchor">anchor</code> attribute to set the implicit anchor element:</p> | ||
|
||
<pre><code class="html"><div id="myanchor">myanchor</div> | ||
<div id="target" anchor="myanchor">target</div> | ||
|
||
<style> | ||
#myanchor { | ||
margin: 100px; | ||
width: 100px; | ||
height: 100px; | ||
} | ||
#target { | ||
position: absolute; | ||
left: anchor(left); | ||
top: anchor(bottom); | ||
width: 100px; | ||
height: 100px; | ||
} | ||
</style></code></pre> | ||
</div> | ||
|
||
|
||
|
||
<h5><dfn>Embedding custom non-visible data</dfn> with the <code data-x="attr-data-*">data-*</code> attributes</h5> | ||
|
||
|
@@ -85284,13 +85334,17 @@ dictionary <dfn dictionary>DragEventInit</dfn> : <span>MouseEventInit</span> { | |
<p>The <span>topmost popover ancestor</span> algorithm will return the topmost (latest in the | ||
<span>showing auto popover list</span>) ancestor popover for the provided popover or top layer | ||
element. Popovers can be related to each other in several ways, creating a tree of popovers. | ||
There are two paths through which one popover (call it the "child" popover) can have a topmost | ||
There are three paths through which one popover (call it the "child" popover) can have a topmost | ||
ancestor popover (call it the "parent" popover):</p> | ||
|
||
<ol> | ||
<li><p>The popovers are nested within each other in the node tree. In this case, the descendant | ||
popover is the "child" and its topmost ancestor popover is the "parent".</p></li> | ||
|
||
<li><p>A popover has the <code data-x="attr-anchor">anchor</code> attribute set and it points | ||
to an element whose ancestor is also a popover. In this case, the popover with the <code | ||
data-x="attr-anchor">anchor</code> attribute is the "child".</p></li> | ||
|
||
<li><p>An invoking element (e.g., a <code>button</code>) has a <code | ||
data-x="attr-popovertarget">popovertarget</code> attribute pointing to a popover. In this case, | ||
the popover is the "child", and the popover subtree the invoking element is in is the | ||
|
@@ -85387,6 +85441,9 @@ dictionary <dfn dictionary>DragEventInit</dfn> : <span>MouseEventInit</span> { | |
<li><p>Run <var>checkAncestor</var> given <var>newPopoverOrTopLayerElement</var>'s parent node | ||
within the <span>flat tree</span>.</p></li> | ||
|
||
<li><p>Run <var>checkAncestor</var> given the result of running <span>get an attribute by | ||
name</span> given <var>newPopover</var> and <code data-x="attr-anchor">anchor</code>.</p></li> | ||
|
||
<li><p>Run <var>checkAncestor</var> given <var>invoker</var>.</p></li> | ||
|
||
<li><p>Return <var>topmostPopoverAncestor</var>.</p></li> | ||
|
@@ -132500,6 +132557,10 @@ dialog:popover-open { | |
background-color: Canvas; | ||
} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What's the intention behind this rule? Doesn't this basically end up showing at the static position? Which is still a bit problematic, see w3c/csswg-drafts#9939. |
||
|
||
[popover][anchor] { | ||
inset: auto; | ||
} | ||
|
||
:popover-open::backdrop { | ||
position: fixed; | ||
inset: 0; | ||
|
@@ -139646,6 +139707,11 @@ interface <dfn interface>External</dfn> { | |
<code data-x="attr-input-alt">input</code> | ||
<td> Replacement text for use when images are not available | ||
<td> <a href="#attribute-text">Text</a>* | ||
<tr> | ||
<th> <code data-x="">anchor</code> | ||
<td> <span data-x="attr-anchor">HTML elements</span> | ||
<td> Sets the <span>implicit anchor element</span> of this element. Also influences the popover hierarchy if the specified element also has the <code data-x="attr-popover">popover</code> attribute. | ||
<td> <span data-x="concept-id">ID</span>* | ||
<tr> | ||
<th> <code data-x="">as</code> | ||
<td> <code data-x="attr-link-as">link</code> | ||
|
@@ -142191,6 +142257,9 @@ INSERT INTERFACES HERE | |
<dt id="refsCSSALIGN">[CSSALIGN]</dt> | ||
<dd><cite><a href="https://w3c.github.io/csswg-drafts/css-align/">CSS Box Alignment</a></cite>, E. Etemad, T. Atkins. W3C.</dd> | ||
|
||
<dt id="refsCSSANCHOR">[CSSANCHOR]</dt> | ||
<dd><cite><a href="https://drafts.csswg.org/css-anchor-position-1/">CSS Anchor Positioning</a></cite>, T. Atkins, J. Tompkins, I. Kilpatrick. W3C.</dd> | ||
|
||
<dt id="refsCSSANIMATIONS">[CSSANIMATIONS]</dt> | ||
<dd><cite><a href="https://w3c.github.io/csswg-drafts/css-animations/">CSS Animations</a></cite>, D. Jackson, D. Hyatt, C. Marrin, S. Galineau, L. Baron. W3C.</dd> | ||
|
||
|
Uh oh!
There was an error while loading. Please reload this page.